//
//  JKProgressHUD.swift
//  ZhiHuDaily-Swift
//
//  Created by albert on 2018/3/6.
//  Copyright © 2018年 安永博. All rights reserved.
//

import UIKit
import SVProgressHUD

class JKProgressHUD: SVProgressHUD {
    
    // MARK: - 初始化
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        initialization()
    }
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        
        initialization()
    }
    
    private func initialization() {
        
        defaultMaskType = SVProgressHUDMaskType.none
        defaultStyle = SVProgressHUDStyle.dark
        minimumDismissTimeInterval = 1.0
        maximumDismissTimeInterval = 1.0
    }
    
    /** 转圈 加载中... */
    public class func showWithLoadingIsAllowUserAction(isAllowUserAction: Bool) {
        
        showWithStatus(status: "加载中...", isAllowUserAction: isAllowUserAction)
    }
    
    /** 自定义转圈状态文字 */
    public class func showWithStatus(status: String, isAllowUserAction: Bool) {
        
        show(withStatus: status)
        
        if (!isAllowUserAction) {
            
            doNotAllowUserAction()
        }
    }
    
    /** doNotAllowUserAction */
    private class func doNotAllowUserAction() {
        
        setDefaultMaskType(SVProgressHUDMaskType.clear)
    }
}
